for port in $(seq 7001 7006); \
do \
mkdir -p /mydata/redis/node-${port}/conf
touch /mydata/redis/node-${port}/conf/redis.conf
cat << EOF >/mydata/redis/node-${port}/conf/redis.conf
port ${port}
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-announce-ip 192.168.0.102
cluster-announce-port ${port}
cluster-announce-bus-port 1${port}
appendonly yes
EOF

docker run -p ${port}:${port} -p 1${port}:1${port} --name=redis-${port} --restart=always \
-v /mydata/redis/node-${port}/data:/data \
-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \
-di redis:5.0.7 redis-server /etc/redis/redis.conf; \
done


docker stop $(docker ps -a |grep redis-700|awk '{print $1}')
docker rm $(docker ps -a |grep redis-700|awk '{print $1}')

#建立Redis集群
docker exec -it redis-7001 /bin/bash
redis-cli --cluster create 192.168.0.102:7001 192.168.0.102:7002 192.168.0.102:7003 192.168.0.102:7004 192.168.0.102:7005 192.168.0.102:7006 --cluster-replicas 1

redis-cli -c -h 192.168.0.102 -p 7001

set bb
set bb aa
cluster info
cluster nodes
